
let objData = [
    {
        id: 1,
        name: "iphone12",
        color: "白色",
        type: "c1",
    }, {
        id: 2,
        name: "华为p30",
        color: "白色",
        type: "c1",
    }, {
        id: 3,
        name: "海尔",
        color: "白色",
        type: "c2",
    },
]

let entendTypeData = [{ code: "c1", name: "手机" }, { code: "c2", name: "电视" }]

let entendFiledsConfig = [
    {
        type: "c1",
        code: "c1-1",
        name: "cpu",
    },
    {
        type: "c1",
        code: "c1-2",
        name: "内存",
    },
    {
        type: "c1",
        code: "c1-3",
        name: "存储",
    },
    {
        type: "c2",
        code: "c2-1",
        name: "尺寸",
    },

];



let extFiledsData = [
    {
        objid: 1,
        filedCode: "c1-1",
        value: "8核"
    }, {
        objid: 1,
        filedCode: "c1-2",
        value: "2G"
    }, {
        objid: 1,
        filedCode: "c1-3",
        value: "64G"
    },
]

//分类
const entendType = {
    url: "/extendType",
    method: "get",
    response: (ops) => {
        let retData = { code: 200, data: [], msg: "" }

        retData.data.push(...entendTypeData);
        return retData;
    }
}
//分类下的扩展字段
//查看
const extFiledConfigQry = {
    url: "/extFiled",
    method: "get",
    response: (ops) => {
        let retData = { code: 200, data: [], msg: "" }

        let params = JSON.parse(ops.body);
        if (params.type) {
            let tmp = entendFiledsConfig.filter(aa => { return aa.type == params.type });
            retData.data.push(...tmp);
        } else {
            retData.data.push(...entendFiledsConfig);
        }

        return retData;
    }
}
//增加
const extFiledConfigAdd = {
    url: "/extFiled",
    method: "put",
    response: (ops) => {
        let retData = { code: 200, data: [], msg: "" }

        let params = JSON.parse(ops.body);
        entendFiledsConfig.push(...params);

        retData.data.push(...entendFiledsConfig);
        return retData;
    }
}




let ret = [];
ret.push(entendType);
ret.push(extFiledConfigQry);
ret.push(extFiledConfigAdd);


export default ret;
